package com.hhxy.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author ghp
 * @date 2022/9/27
 * @Title
 * @description
 */
@WebServlet("/myServlet")
public class MyServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //在Request域总存储数据
        request.setAttribute("username","张三");
        request.setAttribute("password","123");
        //请求转发到myJsp.jsp
        request.getRequestDispatcher("/jsp/my-jsp.jsp").forward(request,response);
    }
}